/**
*	企业信息
**/
app.controller('gCompanyInfoCtrl', ['$scope', '$state', '$stateParams', '$http', '$window', '$cookieStore', 'utils',
  function($scope, $state, $stateParams, $http, $window, $cookieStore, utils) {

    // 后退
    $scope.goBack = function () {
      $window.history.back();
    }

    // 页面配置
    $scope.pageData = {
      loading: true
    }

    // 获取企业信息
    // utils.get('getCompanyDetail', {
    //   'openID': $cookieStore.get('openID') || ''
    //   // openID: '122'
    // }).success(function (rs) {
    //   $scope.pageData = rs.data[0];
    //   $scope.pageData.loading = false;
    // });

    utils.get('checkIfhasJoin', {
      openID: $cookieStore.get('openID') || ''
      // openID: '122'
    })
    .success(function functionName(rs) {
      if(rs.data ==false) {
        $state.go('g.join');
      } else {
        // 获取企业信息
        utils.get('getCompanyDetail', {
          'openID': $cookieStore.get('openID') || ''
          // openID: '122'
        }).success(function (rs) {
          $scope.pageData = rs.data[0];
        });

      }
    })

    // 解绑
    $scope.relaseCompany = function () {
      utils.get('relseaCompany', {
        'openID': $cookieStore.get('openID') || ''
        // openID: '122'
      }).success(function (rs) {
        $state.go('g.join');
      });
    }

  }
]);
